'use strict';

const path = require('path');

module.exports = {
  mode: 'production',
  entry: {
    main: './src/index.js'
  },

  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        use: {
          loader: 'babel-loader',
          options: {
            "presets": [
              [
                "@babel/preset-env",
                {
                  "targets": "defaults"
                }
              ],
              "@babel/preset-react"
            ]
          }
        },
        exclude: /node_modules/
      }
    ],
  },

  resolve: {
    extensions: ['.js', '.jsx']
  },

  output: {
    filename: 'index.js',
    path: path.resolve(__dirname, '../dist'),
    library: {
      root: 'QueryBuilder',
      amd: 'query-builder',
      commonjs: 'query-builder'
    },
    libraryTarget: 'umd'
  },
  externals: {
    'react': {
      commonjs: 'react',
      commonjs2: 'react',
      amd: 'react',
      root: 'React'
    },
    'react-dom': {
      commonjs: 'react-dom',
      commonjs2: 'react-dom',
      amd: 'react-dom',
      root: 'ReactDom'
    },
    lodash: {
      commonjs: 'lodash',
      commonjs2: 'lodash',
      amd: 'lodash',
      root: '_'
    }
  },
  devtool: 'none'
};